<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="5">
            <el-form-item label="校区品牌" prop="brand">
              <el-select v-model="query.brand" placeholder="">
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="校区信息">
              <el-select v-model="query.campusId" placeholder="请选择校区" clearable filterable :loading="campusLoading" @focus="loadCampusOptions" :style="{ width: '100%' }">
                <el-option v-for="item in campusOptions" :key="item.id" :label="item.fullName" :value="item.id" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="管理区域">
              <el-select v-model="query.company" placeholder="请选管理区域" clearable filterable :loading="campusLoading" @focus="loadCampusOptions" :style="{ width: '100%' }">
                <el-option v-for="item in companyOptions" :key="item.enCode" :label="item.label" :value="item.enCode" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="校区阶段" prop="level">
              <el-select v-model="query.level" placeholder="" clearable multiple>
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in levelOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="校区状态">
              <el-select v-model="query.campusStatus" placeholder="" clearable multiple>
                <el-option v-for="item in campusStatusOptions" :key="item.id" :label="item.fullName" :value="item.enCode" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="保险单号">
              <el-input v-model="query.policyNumber" placeholder="请输入保险单号" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="参保状态">
              <el-select v-model="query.status" placeholder="请选择参保状态" filterable clearable required :style="{ width: '100%' }">
                <el-option :key="item.enCode" :label="item.fullName" :value="item.enCode" v-for="item in statusOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="校区区域">
              <custom-address v-model="query.area" :multiple="true" />
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()">新增</el-button>
            <el-button type="text" icon="el-icon-plus" @click="ImportFormHandle()">导入</el-button>
            <el-button type="success" icon="el-icon-s-data" @click="goToStats()">续保率统计</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list">
          <el-table-column prop="brand" label="校区品牌" align="center" width="80">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="shortName" label="校区名称" align="left" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.shortName + '(' + scope.row.enCode + ')' }}
            </template>
          </el-table-column>
          <el-table-column prop="campusStatus" label="校区状态" align="center" width="80">
            <template slot-scope="scope">
              <el-tag size="mini" v-if="scope.row.campusStatus == 'preparation'" key="筹备" type="" effect="dark">
                筹备
              </el-tag>
              <el-tag size="mini" v-if="scope.row.campusStatus == 'normal'" key="正常" type="success" effect="dark">
                正常
              </el-tag>
              <el-tag size="mini" v-if="scope.row.campusStatus == 'expires'" key="到期" type="info" effect="dark">
                待续费
              </el-tag>
              <el-tag size="mini" v-else-if="scope.row.campusStatus == 'suspended'" key="暂停" type="warning" effect="dark">
                暂停
              </el-tag>
              <el-tag size="mini" v-else-if="scope.row.campusStatus == 'close'" key="闭校" type="danger" effect="dark">
                闭校
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="level" label="运营阶段" align="left" width="80">
            <template slot-scope="scope">
              {{ scope.row.level | dynamicCodeText(levelOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="manager" label="校区负责人" align="left" width="120" />
          <el-table-column prop="" label="所在区域" align="left" width="200">
            <template slot-scope="scope">
              {{ scope.row.province }}{{ scope.row.city }}
            </template>
          </el-table-column>
          <el-table-column prop="siteArea" label="校区面积" align="right" width="130" />
          <el-table-column prop="businessName" label="营业执照主体" align="left" show-overflow-tooltip />
          <el-table-column prop="policyStatus" label="参保状态" align="center" width="120"></el-table-column>
          <el-table-column label="参保记录" fixed="right">
            <template slot-scope="scope">
              <el-button type="text" v-if="scope.row.records > 0" @click="recordsHandle(scope.row.campusId)">参保记录（{{ scope.row.records }}）</el-button>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="search" />
    <records-form v-if="recordsVisible" ref="RecordsForm" @refresh="refresh" />
    <import-form v-if="importFormVisible" ref="ImportForm" @refresh="refresh" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
<style lang="scss" scoped>
@import url(index.scss);
</style>
